package com.sfy.core.example.service;

import io.vertx.core.Vertx;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class VertxHttpServer implements HttpServer {
    @Override
    public void doStart(int port) {
        // 创建实例
        Vertx vertx = Vertx.vertx();

        // 创建HTTP服务器
        io.vertx.core.http.HttpServer httpServer = vertx.createHttpServer();

        // 监听端口并处理请求
        httpServer.requestHandler(new HttpServerHandler());

        //启动HTTP服务器并监听指定端口
        httpServer.listen(port, result -> {
            if (result.succeeded()) {
                log.info("服务在{}被监听......",port);
            } else {
                System.err.println("Failed to start server: " + result.cause());
            }
        });
    }
}
